//
//  DYZhusuChoiceView.swift
//  SheYangBigData
//
//  Created by 叁拾叁 on 2021/3/19.
//  Copyright © 2021 叁拾叁. All rights reserved.
//

import UIKit
import SwiftWeb
import SwiftDate

// MARK: -DYZhusuChoiceView
class DYZhusuChoiceView: SYBaseView {
    
    var type: YuleType = .zhusu
    var zhusuParams:[String: String] = [:]
    var jingquParams:[String: String] = [:]
    var meishiParams:[String: String] = [:]
    
    var guanjianciClosure:((String)->Void)?
    var locationClosure:((String, String)->Void)?
    var locationParams:[String: String] = [:]
    let delegate  = DYLocationDelegate()
    var location:LocationManager = LocationManager()
    
    var choiceModel = DYZhuseChoiceModel()
    let renshuChoiceView = DYRenshuChoiceView()
    let ticketChoiceView = DYTicketChoiceView()
    let priceChoiceView = DYPriceChoiceView()
    let riqiChoiceView = DYRiqiChoiceView()
    let riliView = DYRiliView()
    let riliChoiceDaysView = DYRiliChoiceDaysView()
    
    
    var didian: UILabel = {
        let v = UILabel()
        
        v.textColor = UIColor(hex: 0x1E1E1E)
        v.font = 16.autoFontSize()
        return v
    }()
    
    var didianBt: UIButton = {
        let v = UIButton()
        
        return v
    }()
    
    let didianArrow: UIImageView = {
        let v = UIImageView()
        v.image = UIImage(named: "arrow")
        return v
    }()
    
    let guanjianciArrow: UIImageView = {
        let v = UIImageView()
        v.image = UIImage(named: "arrow")
        v.isHidden = true
        return v
    }()
    
    let priceArrow: UIImageView = {
        let v = UIImageView()
        v.image = UIImage(named: "arrow")
        return v
    }()
    
    let leixingArrow: UIImageView = {
        let v = UIImageView()
        v.image = UIImage(named: "arrow")
        return v
    }()
    
    var dingwei: VGBaseTitleImgView = {
        let v = VGBaseTitleImgView()
        v.textLb.text = "我的位置"
        v.textLb.textColor = UIColor(hex: 0xC3C3C3)
        v.textLb.font = 14.autoFontSize()
        v.imageV.sy_name("dingwei")
        return v
    }()
    
    var dingweiBt: UIButton = {
        let v = UIButton()
        
        return v
    }()
    
    var kaishi: UILabel = {
        let v = UILabel()
        v.font = 15.autoFontSize()
        v.textColor = UIColor(hex: 0x1E1E1E)
        return v
    }()
    
    var jiesu: UILabel = {
        let v = UILabel()
        v.font = 15.autoFontSize()
        v.textColor = UIColor(hex: 0x1E1E1E)
        return v
    }()
    
    var zongji: UILabel = {
        let v = UILabel()
        v.font = 13.autoFontSize()
        v.textColor = UIColor(hex: 0x1E1E1E)
        v.textAlignment = .right
        return v
    }()
    
    var kaishiBt: UIButton = {
        let v = UIButton()
        return v
    }()
    
    var jiesuBt: UIButton = {
        let v = UIButton()
        return v
    }()
    
    var zongjiBt: UIButton = {
        let v = UIButton()
        return v
    }()
    
    var leixing: UILabel = {
        let v = UILabel()
        v.font = 14.autoFontSize()
        v.textColor = UIColor(hex: 0x1E1E1E)
        
        return v
    }()
    
    var leixingBt: UIButton = {
        let v = UIButton()
        return v
    }()
    
    var guanjianci: UITextField = {
        let v = UITextField()
        v.placeholder = "酒店/地名/关键词"
        v.font = 14.autoFontSize()
        v.textColor = UIColor(hex: 0x1E1E1E)
        return v
    }()
    
    var price: UITextField = {
        let v = UITextField()
        v.placeholder = "价格/星级"
        v.font = 14.autoFontSize()
        v.textColor = UIColor(hex: 0x1E1E1E)
        return v
    }()
    
//    var guanjianciBt: UIButton = {
//        let v = UIButton()
//        return v
//    }()
    
    var priceBt: UIButton = {
        let v = UIButton()
        return v
    }()
    
    public var secLineView: UIView = {
        let v: UIView = UIView()
        v.backgroundColor = UIColor(hex: 0xE6E6E6)
        return v
    }()
    
    public var thirLineView: UIView = {
        let v: UIView = UIView()
        v.backgroundColor = UIColor(hex: 0xE6E6E6)
        return v
    }()
    
    init(frame: CGRect, currentVC: SYBaseViewController, type: YuleType) {
        super.init(frame: frame)
        self.currentVC = currentVC
        self.type = type
        renshuChoiceView.type = self.type
        priceChoiceView.type = self.type
        initView()
    }
    
    required init?(coder: NSCoder) {
        fatalError("init(coder:) has not been implemented")
    }

    
    func configure(_ choiceModel: DYZhuseChoiceModel) {
        
        zongji.text = choiceModel.gong
        leixing.text = choiceModel.renshu
        price.text = choiceModel.price
        guanjianci.text = choiceModel.guanjianci
        
        kaishi.attributedText = setDayText(choiceModel.start, choiceModel.startTip)
        jiesu.attributedText = setDayText(choiceModel.end, choiceModel.endTip)
    }
    
    // 定位
    fileprivate func gpsService() {
        
        delegate.location = location
        delegate.currentVC = self.currentVC
        delegate.gpsClosure = {[weak self] (lon,lat) in
            if let `self` = self {
                
                switch self.type {
                case .zhusu:
                    self.zhusuParams["longitude"] = "\(lon)"
                    self.zhusuParams["latitude"] = "\(lat)"
                    print("zhusuParams", self.zhusuParams)
                case .jingqu:
                    self.jingquParams["longitude"] = "\(lon)"
                    self.jingquParams["latitude"] = "\(lat)"
                    print("jingquParams", self.jingquParams)
                case .meishi:
                    self.meishiParams["longitude"] = "\(lon)"
                    self.meishiParams["latitude"] = "\(lat)"
                    print("meishiParams", self.meishiParams)
                }
            }
        }
        delegate.locationClosure = {[weak self] (area,locality,subLocality,thoroughfare,name) in
            if let `self` = self {
                self.didian.text = locality+subLocality+thoroughfare
                self.locationParams = ["name": subLocality, "address": locality+subLocality+thoroughfare, "locationName": name]
            }
        }
        location.locationProtocol = delegate
        //只获取一次
//        isOnece = true
    }
    
    func setDayText(_ text: String, _ tip: String) -> NSMutableAttributedString {
        let firStr = "\(text)"
        let totalStr = "\(text) \(tip)"
        let attString = NSMutableAttributedString(string: totalStr)
        attString.yy_setColor(UIColor(hex: 0x1E1E1E), range: NSRange(location: 0, length: firStr.count))
        attString.yy_setFont(15.autoFontSize(), range: NSRange(location: 0, length:firStr.count))
        attString.yy_setColor(UIColor(hex: 0x1E1E1E), range: NSRange(location: firStr.count, length: totalStr.count - firStr.count))
        attString.yy_setFont(13.autoFontSize(), range: NSRange(location: firStr.count, length: totalStr.count - firStr.count))
        return attString
    }
    
    func setTicketChoiceView() {
        ticketChoiceView.currentVC = self.currentVC
        ticketChoiceView.idsClosure = {[weak self] (ids, titles) in
            if let `self` = self {
                
                self.jingquParams["scenicTicketIds"] = ids.joined(separator: ",")
                self.leixing.text = titles.joined(separator: ",")
            }
        }
        ticketChoiceView.modelClosure = {[weak self] (models) in
            if let `self` = self {
                let ms = models.filter { $0.dictionaryName == "成人票" }
                self.jingquParams["scenicTicketIds"] = ms.first?.id
            }
        }
        self.currentVC.view.addSubview(ticketChoiceView)
        ticketChoiceView.snp.makeConstraints { (make) in
            make.bottom.equalToSuperview()
            make.top.left.right.equalToSuperview()
        }
    }
    
    func setRenshuChoiceView() {
        renshuChoiceView.currentVC = self.currentVC
        renshuChoiceView.numsClosure = {[weak self] nums in
            if let `self` = self {
                let vc = (self.currentVC as! DYDaoLanViewController)
                
                switch self.type {
                case .zhusu:
                    self.zhusuParams["adult"] = "\(nums[0])"
                    self.zhusuParams["child"] =  "\(nums[1])"
                    self.zhusuParams["baby"] = "\(nums[2])"
                    self.zhusuParams["bed"] = "\(nums[3])"
                    
                    let titles = vc.roomModels.map { $0.strK }
                    self.leixing.text = "\(nums[0])\(titles[0] ?? "")\(nums[1])\(titles[1] ?? "")\(nums[2])\(titles[2] ?? "")\(nums[3])\(titles[3] ?? "")"
                    print("zhusuParams", self.zhusuParams)
                case .meishi:
                    self.meishiParams["peopleNum"] = "\(nums[0])"
                    self.leixing.text = "\(nums[0])位"
                    print("meishiParams", self.meishiParams)
                default:
                    break
                }
            }
        }
        self.currentVC.view.addSubview(renshuChoiceView)
        renshuChoiceView.snp.makeConstraints { (make) in
            make.bottom.equalToSuperview()
            make.top.left.right.equalToSuperview()
        }
    }
    
    func setPriceChoiceView() {
        priceChoiceView.currentVC = self.currentVC
        priceChoiceView.priceClosure = {[weak self] (r, h) in
            if let `self` = self {
                
                switch self.type {
                case .zhusu:
                    self.zhusuParams["rates"] = r
                    if h.isEmpty {
                        self.zhusuParams.removeValue(forKey: "maxRates")
                    } else {
                        self.zhusuParams["maxRates"] = h
                    }
                    print("zhusuParams", self.zhusuParams)
                case .jingqu:
                    self.jingquParams["rates"] = r
                    if h.isEmpty {
                        self.jingquParams.removeValue(forKey: "maxRates")
                    } else {
                        self.jingquParams["maxRates"] = h
                    }
                    print("jingquParams", self.jingquParams)
                case .meishi:
                    self.meishiParams["cost"] = r
                    if h.isEmpty {
                        self.meishiParams.removeValue(forKey: "maxCost")
                    } else {
                        self.meishiParams["maxCost"] = h
                    }
                    print("meishiParams", self.meishiParams)
                }
            }
        }
        priceChoiceView.starClosure = {[weak self] (s) in
            if let `self` = self {
                switch self.type {
                case .zhusu:
                    self.zhusuParams["typeStr"] = s
                    print("zhusuParams", self.zhusuParams)
                default:
                    break
                }
            }
        }
        priceChoiceView.compClosure = {[weak self] (s) in
            if let `self` = self {
                self.price.text = s
                print("compClosure", s)
            }
        }
        self.currentVC.view.addSubview(priceChoiceView)
        priceChoiceView.snp.makeConstraints { (make) in
            make.bottom.equalToSuperview()
            make.top.left.right.equalToSuperview()
        }
    }
    
    
    func setRiqiChoiceView() {
        riqiChoiceView.currentVC = self.currentVC
        riqiChoiceView.compClosure = {[weak self] (startParam, endParam, startStr, sancan, shijianduan) in
            if let `self` = self {
                self.meishiParams["startDate"] = startParam
                self.meishiParams["endDate"] = endParam
                self.kaishi.text = startStr
                self.jiesu.text = sancan
                self.zongji.text = shijianduan
            }
        }
        
        self.currentVC.view.addSubview(riqiChoiceView)
        riqiChoiceView.snp.makeConstraints { (make) in
            make.bottom.equalToSuperview()
            make.top.left.right.equalToSuperview()
        }
    }
    
    func setRiliView() {
        riliView.currentVC = self.currentVC
        riliView.compClosure = {[weak self] (param, dateStr) in
            if let `self` = self {
                self.jingquParams["date"] = param
                self.kaishi.text = dateStr
            }
        }
        self.currentVC.view.addSubview(riliView)
        riliView.snp.makeConstraints { (make) in
            make.bottom.equalToSuperview()
            make.top.left.right.equalToSuperview()
        }
    }
    
    func setRiliChoiceDaysView() {
        riliChoiceDaysView.currentVC = self.currentVC
        riliChoiceDaysView.passParamsClosure = {[weak self] (params) in
            if let `self` = self {
                
                switch self.type {
                case .zhusu:
                    let s = params as! (Date, Date, Int)
                    let start = "\(s.0.month)月\(s.0.day)日"
                    let end = "\(s.1.month)月\(s.1.day)日"
                    self.kaishi.attributedText = self.setDayText(start, self.isTodayOrTomorrow(s.0))
                    self.jiesu.attributedText = self.setDayText(end, self.isTodayOrTomorrow(s.1))
                    self.zongji.text = "共\(s.2)晚"
                    
                    self.zhusuParams["startDate"] = "\(s.0.year)-\(s.0.month)-\(s.0.day)"
                    self.zhusuParams["endDate"] = "\(s.1.year)-\(s.1.month)-\(s.1.day)"
                    print("zhusuParams", self.zhusuParams)
                    
                case .jingqu:
                    let s = params as! (Date, Date, Int)
                    let start = "\(s.0.month)月\(s.0.day)日"
                    self.kaishi.attributedText = self.setDayText(start, self.isTodayOrTomorrow(s.0))
                    
                    self.zhusuParams["date"] = "\(s.0.year)-\(s.0.month)-\(s.0.day)"
                    print("jingquParams", self.jingquParams)
                    
                case .meishi:
                    let s = params as! (Date, Date, Int)
                    let start = "\(s.0.month)月\(s.0.day)日"
                    self.kaishi.attributedText = self.setDayText(start, self.isTodayOrTomorrow(s.0))
                    self.jiesu.attributedText = self.setDayText("晚餐", "")
                    self.zongji.text = "11:00-12:00"
                    
                    self.zhusuParams["startDate"] = "\(s.0.year)-\(s.0.month)-\(s.0.day) 11:00:00"
                    self.zhusuParams["endDate"] = "\(s.0.year)-\(s.0.month)-\(s.0.day) 12:00:00"
                    print("meishiParams", self.meishiParams)
                }
            }
        }
        self.currentVC.view.addSubview(riliChoiceDaysView)
        riliChoiceDaysView.snp.makeConstraints { (make) in
            make.bottom.equalToSuperview()
            make.top.left.right.equalToSuperview()
        }
    }
    
    func initView() {
        
        setRenshuChoiceView()
        setPriceChoiceView()
        setRiqiChoiceView()
        setRiliView()
        setRiliChoiceDaysView()
        setTicketChoiceView()
        
        gpsService()
//        GaodeManager().getLocationInfo()
        self.location.startLocation()
        didianBt.addAction {[weak self] in
            if let `self` = self {
                let vc = DYLocationViewController(params: self.locationParams)
                vc.passParamsClosure = {[weak self] value in
                    if let `self` = self {
                        let info = value as! (String, String)
                        let gpss = info.0.components(separatedBy: ",")

                        let lon = gpss.first ?? ""
                        let lat = gpss.last ?? ""
                        switch self.type {
                        case .zhusu:
                            self.zhusuParams["longitude"] = lon
                            self.zhusuParams["latitude"] = lat
                            print("zhusuParams", self.zhusuParams)
                        case .jingqu:
                            self.jingquParams["longitude"] = lon
                            self.jingquParams["latitude"] = lat
                            print("jingquParams", self.jingquParams)
                        case .meishi:
                            self.meishiParams["longitude"] = lon
                            self.meishiParams["latitude"] = lat
                            print("meishiParams", self.meishiParams)
                        }
                        self.didian.text = info.1
                        self.locationParams = ["name": info.1, "address": info.1, "locationName": info.1]
                    }
                }
                self.currentVC.sy_push(vc)
            }
        }
        dingweiBt.addAction {[weak self] in
            if let `self` = self {
                self.location.startLocation()
            }
        }
        kaishiBt.addAction {[weak self] in
            if let `self` = self {
                print("kaishiBt")
                self.riqiChoice()
            }
        }
        jiesuBt.addAction {[weak self] in
            if let `self` = self {
                print("jiesuBt")
                self.riqiChoice()
            }
        }
        zongjiBt.addAction {[weak self] in
            if let `self` = self {
                print("zongjiBt")
                self.riqiChoice()
            }
        }
//        guanjianciBt.addAction {[weak self] in
//            if let `self` = self {
//                print("guanjianciBt")
//            }
//        }
        priceBt.addAction {[weak self] in
            if let `self` = self {
                print("priceBt")
                self.priceChoiceView.show()
            }
        }
        leixingBt.addAction {[weak self] in
            if let `self` = self {
                print("leixingBt")
                
                switch self.type {
                case .zhusu:
                    self.renshuChoiceView.show()
                case .jingqu:
                    self.ticketChoiceView.show()
                case .meishi:
                    self.renshuChoiceView.show()
                }
            }
        }
        
        //当文本框内容改变时，将内容输出到控制台上
        guanjianci.rx.text.orEmpty.asObservable()
            .subscribe(onNext: {[weak self] in
                if let `self` = self {
//                    self.guanjianciClosure?($0)
                    switch self.type {
                    case .zhusu:
                        self.zhusuParams["name"] = $0
                        print("zhusuParams", self.zhusuParams)
                    case .jingqu:
                        self.jingquParams["name"] = $0
                        print("jingquParams", self.jingquParams)
                    case .meishi:
                        self.meishiParams["name"] = $0
                        print("meishiParams", self.meishiParams)
                    }
                }
                print("您输入的是：\($0)")
            })
            .disposed(by: disposeBag)
        //        didianBt.backgroundColor = .blue
        //        kaishiBt.backgroundColor = .yellow
        //        jiesuBt.backgroundColor = .red
        //        zongjiBt.backgroundColor = .purple
        //        guanjianciBt.backgroundColor = .gray
        //        priceBt.backgroundColor = .orange
        //        leixingBt.backgroundColor = .black
        switch type {
        case .zhusu:
            setZhusuChoiceModel()
        case .jingqu:
            setJingquChoiceModel()
        case .meishi:
            setMeishiChoiceModel()
        
        }
        
        addSubview(didian)
        addSubview(didianBt)
        addSubview(didianArrow)
        addSubview(guanjianciArrow)
        addSubview(priceArrow)
        addSubview(leixingArrow)
        
        addSubview(dingwei)
        addSubview(dingweiBt)
        addSubview(kaishi)
        addSubview(jiesu)
        addSubview(zongji)
        addSubview(kaishiBt)
        addSubview(jiesuBt)
        addSubview(zongjiBt)
        
        addSubview(leixing)
        addSubview(leixingBt)
        addSubview(guanjianci)
//        addSubview(guanjianciBt)
        addSubview(price)
        addSubview(priceBt)
        addSubview(lineView)
        addSubview(secLineView)
        addSubview(thirLineView)
        
        didian.snp.makeConstraints { (make) in
            make.top.equalToSuperview()
            make.left.equalToSuperview().offset(17.autoWidth())
            make.right.equalTo(didianArrow.snp.left)
            make.height.equalTo(40.autoWidth())
        }
        didianBt.snp.makeConstraints { (make) in
            make.top.equalToSuperview()
            make.left.equalToSuperview().offset(17.autoWidth())
            make.right.equalTo(didianArrow.snp.right)
            make.height.equalTo(40.autoWidth())
        }
        dingwei.snp.makeConstraints { (make) in
            make.top.equalToSuperview()
            make.right.equalToSuperview().offset(-17.autoWidth())
            make.height.equalTo(40.autoWidth())
            make.width.equalTo(80.autoWidth())
        }
        dingweiBt.snp.makeConstraints { (make) in
            make.top.equalToSuperview()
            make.right.equalToSuperview().offset(-17.autoWidth())
            make.height.equalTo(40.autoWidth())
            make.width.equalTo(80.autoWidth())
        }
        didianArrow.snp.makeConstraints { (make) in
            make.top.equalToSuperview().offset(15.autoWidth())
            make.right.equalToSuperview().offset(-102.autoWidth())
            make.height.equalTo(10.autoWidth())
            make.width.equalTo(6.autoWidth())
        }
        
        kaishi.snp.makeConstraints { (make) in
            make.top.equalToSuperview().offset(40.autoWidth())
            make.left.equalToSuperview().offset(17.autoWidth())
            make.right.equalTo(jiesu.snp.left)
            make.height.equalTo(40.autoWidth())
        }
        jiesu.snp.makeConstraints { (make) in
            make.top.equalToSuperview().offset(40.autoWidth())
            make.centerX.equalToSuperview()
            make.height.equalTo(40.autoWidth())
            make.right.equalTo(zongji.snp.left)
        }
        zongji.snp.makeConstraints { (make) in
            make.top.equalToSuperview().offset(40.autoWidth())
            make.right.equalToSuperview().offset(-17.autoWidth())
            make.height.equalTo(40.autoWidth())
        }
        kaishiBt.snp.makeConstraints { (make) in
            make.top.equalToSuperview().offset(40.autoWidth())
            make.left.equalToSuperview().offset(17.autoWidth())
            make.width.equalTo(kaishi)
            make.height.equalTo(40.autoWidth())
        }
        jiesuBt.snp.makeConstraints { (make) in
            make.top.equalToSuperview().offset(40.autoWidth())
            make.centerX.equalToSuperview()
            make.height.equalTo(40.autoWidth())
            make.width.equalTo(jiesu)
        }
        zongjiBt.snp.makeConstraints { (make) in
            make.top.equalToSuperview().offset(40.autoWidth())
            make.right.equalToSuperview().offset(-17.autoWidth())
            make.height.equalTo(40.autoWidth())
            make.width.equalTo(zongji)
        }
        
        guanjianci.snp.makeConstraints { (make) in
            make.top.equalToSuperview().offset(80.autoWidth())
            make.left.equalToSuperview().offset(17.autoWidth())
            make.height.equalTo(40.autoWidth())
            make.right.equalTo(guanjianciArrow.snp.left)
        }
        guanjianciArrow.snp.makeConstraints { (make) in
            make.top.equalToSuperview().offset(95.autoWidth())
            make.height.equalTo(10.autoWidth())
            make.width.equalTo(6.autoWidth())
            make.right.equalToSuperview().offset(-17.autoWidth())
        }
//        guanjianciBt.snp.makeConstraints { (make) in
//            make.top.equalToSuperview().offset(80.autoWidth())
//            make.left.equalToSuperview().offset(17.autoWidth())
//            make.height.equalTo(40.autoWidth())
//            make.right.equalToSuperview()
//        }
        
        price.snp.makeConstraints { (make) in
            make.top.equalToSuperview().offset(120.autoWidth())
            make.left.equalToSuperview().offset(17.autoWidth())
            make.height.equalTo(40.autoWidth())
            make.right.equalTo(priceArrow.snp.left)
        }
        priceArrow.snp.makeConstraints { (make) in
            make.top.equalToSuperview().offset(135.autoWidth())
            make.centerX.equalToSuperview()
            make.height.equalTo(10.autoWidth())
            make.width.equalTo(6.autoWidth())
        }
        priceBt.snp.makeConstraints { (make) in
            make.top.equalToSuperview().offset(120.autoWidth())
            make.left.equalToSuperview().offset(17.autoWidth())
            make.height.equalTo(40.autoWidth())
            make.right.equalTo(priceArrow.snp.right)
        }
        
        leixing.snp.makeConstraints { (make) in
            make.top.equalToSuperview().offset(120.autoWidth())
            make.right.equalToSuperview().offset(-34.autoWidth())
            make.height.equalTo(40.autoWidth())
        }
        leixingArrow.snp.makeConstraints { (make) in
            make.top.equalToSuperview().offset(135.autoWidth())
            make.right.equalToSuperview().offset(-17.autoWidth())
            make.height.equalTo(10.autoWidth())
            make.width.equalTo(6.autoWidth())
        }
        leixingBt.snp.makeConstraints { (make) in
            make.top.equalToSuperview().offset(120.autoWidth())
            make.right.equalToSuperview().offset(-17.autoWidth())
            make.left.equalTo(priceArrow.snp.right)
            make.height.equalTo(40.autoWidth())
        }
        
        lineView.snp.makeConstraints { (make) in
            make.top.equalToSuperview().offset(40.autoWidth())
            make.left.equalToSuperview().offset(17.autoWidth())
            make.right.equalToSuperview().offset(-17.autoWidth())
            make.height.equalTo(0.5.autoWidth())
        }
        secLineView.snp.makeConstraints { (make) in
            make.top.equalToSuperview().offset(80.autoWidth())
            make.left.equalToSuperview().offset(17.autoWidth())
            make.right.equalToSuperview().offset(-17.autoWidth())
            make.height.equalTo(0.5.autoWidth())
        }
        thirLineView.snp.makeConstraints { (make) in
            make.top.equalToSuperview().offset(120.autoWidth())
            make.left.equalToSuperview().offset(17.autoWidth())
            make.right.equalToSuperview().offset(-17.autoWidth())
            make.height.equalTo(0.5.autoWidth())
        }
    }
    
    func riqiChoice() {
        
        switch self.type {
        case .zhusu:
            self.riliChoiceDaysView.isHidden = false
        case .jingqu:
            self.riliView.isHidden = false
        case .meishi:
            self.riqiChoiceView.isHidden = false
        }
    }
    
    func setZhusuChoiceModel() {
        let now:Date = Date()
        let tom:Date = now + 1.days
        let today = "\(now.month)月\(now.day)日"
        let tomorrow = "\(tom.month)月\(tom.day)日"
           self.choiceModel.start = today
           self.choiceModel.end = tomorrow
           self.choiceModel.startTip = "今天"
           self.choiceModel.endTip = "明天"
           self.choiceModel.gong = "共\(1)晚"
           self.choiceModel.renshu = "\(1)成人\(0)儿童\(0)婴儿"
           self.choiceModel.price = ""
           self.zhusuParams["startDate"] = "\(now.year)-\(now.month)-\(now.day)"
           self.zhusuParams["endDate"] = "\(tom.year)-\(tom.month)-\(tom.day)"
           self.zhusuParams["adult"] = "1"
           self.zhusuParams["child"] = "0"
           self.zhusuParams["baby"] = "0"
           self.zhusuParams["bed"] = "0"
           self.zhusuParams["typeStr"] = ""
           self.zhusuParams["rates"] = ""
           self.zhusuParams["maxRates"] = ""
           self.zhusuParams["name"] = ""
        
           self.configure(self.choiceModel)
    }
    
    func setJingquChoiceModel() {
        let now:Date = Date()
        let today = "\(now.month)月\(now.day)日"
           self.choiceModel.start = today
           self.choiceModel.end = ""//"晚餐"
           self.choiceModel.startTip = now.isToday ? "今天" : ""
           self.choiceModel.endTip = ""
           self.choiceModel.gong = ""
           self.choiceModel.renshu = "成人票"
           self.choiceModel.price = ""
           self.jingquParams["name"] = ""
           self.jingquParams["rates"] = ""
           self.jingquParams["maxRates"] = ""
           self.jingquParams["date"] = ""
           self.jingquParams["scenicTicketIds"] = ""
        
           self.configure(self.choiceModel)
    }
    
    func setMeishiChoiceModel() {
        let now:Date = Date()
        let today = "\(now.month)月\(now.day)日"
           self.choiceModel.start = today
           self.choiceModel.end = ""
           self.choiceModel.startTip = now.isToday ? "今天" : ""
           self.choiceModel.endTip = ""
           self.choiceModel.gong = ""
           self.choiceModel.renshu = "1位"
           self.choiceModel.price = ""
           self.meishiParams["name"] = ""
           self.meishiParams["cost"] = ""
           self.meishiParams["maxCost"] = ""
           self.meishiParams["peopleNum"] = ""
           self.meishiParams["startDate"] = "\(now.year)-\(now.month)-\(now.day) 11:00:00"
           self.meishiParams["endDate"] = "\(now.year)-\(now.month)-\(now.day) 11:00:00"
           self.configure(self.choiceModel)
    }
}


class DYZhuseChoiceModel: NSObject {
    
//    var type: YuleType = .zhusu
    var start: String = ""
    var end: String = ""
    var startTip: String = ""
    var endTip: String = ""
    var gong: String = ""
    var price: String = ""
    var xingji: String = ""
    var renshu: String = ""
    var guanjianci: String = ""
}

